package com.hsy.dormmanage.controller;

import com.hsy.dormmanage.common.result.Constants;
import com.hsy.dormmanage.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * 包名:com.hsy.dormmanage.controller
 * 用户:86182
 * 时间:20211120:492021/11/20
 */
@Api(value = "退出登录")
@RestController
@RequestMapping("dorm")
public class LogoutController {
    @ApiOperation(value = "退出登录")
    @GetMapping("logout")
    public Result loginOut(HttpSession session, Model model){
        Object o = session.getAttribute(Constants.LOGIN_USER);
        if (o!=null){
            session.removeAttribute(Constants.LOGIN_USER);
            model.addAttribute("msg","退出登录成功！");
            return Result.ok();
        }
        return Result.fail();
    }
}
